<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>

<style>
  .container1 {
    width: 100%;
    height: 100px;
    align-items: center;

    /*元素水平居中*/
    margin-top: 30px;
    margin-bottom: 30px;

  }

  .first {
    display: flex;
    flex-direction: row;
    text-align: left;
  }

  .name1 {
    font-size: 16px;
  }

  .name2 {
    font-size: 16px;
  }

  .name3 {
    font-size: 16px;
  }



  .button1 {
    background-color: rgb(48, 43, 43);
    color: white;
  }

  .button2 {
    background-color: rgb(48, 43, 43);
    color: white;
  }

  .button3 {
    background-color: rgb(48, 43, 43);
    color: white;
  }

  .button4 {
    background-color: rgb(48, 43, 43);
    color: white;
  }

  .container2 {
    width: 100%;
    height: 600px;
    align-items: center;

    /*边框*/
    /*元素水平居中*/
  }

  .demo-ruleForm {
    width: 30%;
  }

  .block {
    text-align: center;
  }
</style>

<body>

  <div id="app">
    <!-- <el-dialog title="评论修改" :visible.sync="alertUser" width="50%">
      <el-form :model="alertForm" ref="alertForm" label-width="100px">
        <el-form-item label="ID">
          <el-input v-model="alertForm.id" :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="评论IDSN">
          <el-input v-model="alertForm.name" :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="重量" prop="phone">
          <el-input maxlength="11" v-model="alertForm.phone"></el-input>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input v-model="alertForm.address"></el-input>
        </el-form-item>
        <el-form-item label="简介" prop="info">
          <el-input v-model="alertForm.info"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="updatepig" type="primary" size="small">保存 </el-button>
        </el-form-item>
      </el-form>

    </el-dialog> -->
    <!-- <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="评论isdn：">
        <el-input v-model="formInline.user" placeholder="评论isdn"></el-input>
      </el-form-item>
      <el-form-item label="评论批次：">
        <el-select v-model="formInline.groupid" placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="searchuser">查询</el-button>
      </el-form-item>
    </el-form> -->
    <div class="container2">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="评论列表" name="first">
          <el-table ref="multipleTable" border :data="commentlist" tooltip-effect="dark" style="width: 100%"
            @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55">
            </el-table-column>

            <el-table-column prop="id" label="评论IDSN" width="120">
              <template slot-scope="scope">
                {{scope.row.id}}
              </template>
            </el-table-column>
            <el-table-column prop="info" label="评论内容" show-overflow-tooltip>
              <template slot-scope="scope">
                {{scope.row.content}}
              </template>
            </el-table-column>

            <el-table-column prop="age" label="电影" show-overflow-tooltip>
              <template slot-scope="scope">
                {{scope.row.moviedata.name}}
              </template>
            </el-table-column>

            <el-table-column prop="status" label="用户" show-overflow-tooltip>

              <template slot-scope="scope">
                {{scope.row.userdata.name}}
              </template>
            </el-table-column>

            <el-table-column fixed="right" label="操作" width="120">
              <template slot-scope="scope">
                <el-button @click.native.prevent="deleteRow(scope.$index)" type="text" size="small">
                  删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>

        </el-tab-pane>

      </el-tabs>

    </div>
  </div>

</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.bootcss.com/axios/0.19.2/axios.js"></script>

<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      alertUser: false,
      alertForm: {
        id: 2,
        name: '',
        password: '',
        phone: '',
        address: '',
        info: '',
      },
      ruleForm: {
        idsn: '',
        age: '',
        ruleForm: '',
        address: '',
        info: '',
        groupid: "",
      }, options: [{
        value: '4',
        label: '销售员'
      },],

      formInline: {
        user: '',
        groupid: ''
      },

      activeName: 'first',
      commentlist: [],
      multipleSelection: [],
      currentPage3: 5,
    },
    mounted() {
      this.getComment();
    },
    methods: {
      updatepig() {
        axios.post("/altUser", this.alertForm).then(res => {
          console.log(res.data)
          if (res.data.result == "ok") {
            this.$notify.success({
              title: '成功',
              message: '修改员工信息成功'
            })
            console.log(res.data)
            return;
          }
        })
      },
      createpig() {
        axios.post("/pig/addPig", this.ruleForm).then(res => {
          console.log(res.data)
          if (res.data.result == "ok") {
            this.$notify.success({
              title: '成功',
              message: '添加评论成功'
            })
            console.log(res.data)
            return;
          }
        })
      },
      searchuser() {

      },
      getComment() {

        axios.post("/comment/getAllComment", {}).then(res => {
          console.log(res);
          if (res.data.result == "ok") {
            res.data.data.forEach(ele => {
              this.commentlist.push(ele)
            })
          }

          console.log(this.userList)
        })
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      handleClick(tab, event) {

      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      handleDelete(index, row) {
        console.log(index, row);
      },
      deleteRow(index) {
        axios.post("/comment/delComment", { id: this.commentlist[index].id }).then(res => {
          console.log(res);
          if (res.data.result == "ok")
            this.commentlist.splice(index, 1)
          this.$notify.success({
            title: '删除成功',
            message: '删除员工成功！'
          })
        })
      },
      alertRow(index, row) {
        this.alertUser = true;
        this.alertForm.id = row[index].id;
        this.alertForm.name = row[index].name;
        this.alertForm.phone = row[index].phone;
        this.alertForm.address = row[index].address;
        this.alertForm.info = row[index].info;
        this.alertForm.password = row[index].password;
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      }
    }
  })
</script>

</html>